import junit.framework.TestCase; import junit.framework.Assert; public class MyMathTest extends TestCase { public void testAbsNegative() { // Purpose: test that abs() works for a value < 0. int testValueX; // Test data for calling method int expected; // Value we expect to see as result int actual; // Actual value that method returns // Test data for method testValueX = -4; // Expected and actual results expected = 4; actual = MyMath.abs( testValueX ); // Check if we have expected results Assert.assertEquals( expected, actual ); } public void testAbsPositive() { // Purpose: produce a 'fail' result. int testValueX; // Test data for calling method int expected; // Value we expect to see as result int actual; // Actual value that method returns // Test data for method testValueX = 4; // Expected and actual results expected = 4; actual = MyMath.abs( testValueX ); // Check if we have expected results Assert.assertEquals( expected, actual ); } }